<?php

require_once('php/lib/mvc/controller.php');
config('BrowseController', 'browse_controller');

class BrowseController extends Controller {
		
	function init() {
		$this->test = false;
		# initialize data sources
		require_once('php/databases/helios_database.php');
		require_once('php/models/helios.php');
		require_once('php/views/yapter_view.php');
		$this->helios_database =& new heliosDatabase();
		$this->helios = new Helios($this->helios_database);			
	}
	
	/**
	 * Standard function when nothing else was called. This function will call viewsettings()
	 * 
	 */
	function view() {
		$view = new YapterView('content/browse.tpl');
		
		if ($_GET['id'])
		{
			$rows = $this->helios->getFoldersByParentId($_GET['id']);					
		} else {
			$rows = $this->helios->getFoldersByParentId(0);
		}
		
		foreach ($rows as $row) {
			$view->replace('results', 'folder');
			$view->set('id', $row['id']);
			$view->set('name', $row['name']);
			$view->parse('results');
		}
		
		return $view;
	}
}

?>